package com.example.tijian_doctor_backend.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.tijian_doctor_backend.pojo.Doctor;
import com.example.tijian_doctor_backend.result.Result;
import com.example.tijian_doctor_backend.service.DoctorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: bong~
 * @description: TODO
 * @date: 2024/6/20 11:07
 * @version: 1.0
 */
@RestController
@Slf4j
@RequestMapping("/doctor")
@Api(tags ="医生接口")
@CrossOrigin("*")
public class DoctorController {

    @Autowired
    private DoctorService doctorService;


    @ApiOperation(value = "医生登录接口",notes = "根据医生编码和密码进行登录")
    @PostMapping("/getDoctorByCodeByPass")
    public Result login(@RequestBody Doctor doctor){

        System.out.println(doctor);

        String docCode= doctor.getDocCode();
        String password=doctor.getPassword();

        QueryWrapper queryWrapper=new QueryWrapper<Doctor>().eq("docCode",docCode).eq("password",password);

        Doctor cur=doctorService.getOne(queryWrapper);

        if(cur==null){
            return Result.error("登录失败，请检查登录信息");
        }

        return Result.success(cur);



    }
}
